<?php
require_once './common.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title></title>
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/jquery.ui.all.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/do.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/flexigrid.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo SITEURI; ?>/inc/style/autocomplete.css"/>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery-1.7.1.js"></script> 
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery-ui-1.8.17.custom.min.js"></script> 
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.layout-latest.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.layout.callbacks.min-latest.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.cookie.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.hotkeys.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.jstree.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/lib/jquery.autocomplete.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/inputvalue.js"></script>
        <script type="text/javascript" src="<?php echo SITEURI; ?>/inc/js/flexigrid.js"></script>
        <script type="text/javascript">
            $(function(){
                $("#dttree").jstree({
                    "themes" : {
                        "theme" : "default",
                        "dots" : false,
                        "icons" : false
                    },
                    "json_data" : {
                        "data": [{"attr" : {"id" : "li_4"}, "data": {"title":"disease","attr":{"id":"4", "href": "javascript:void(0);","class":"treenode"}},"state": "closed"}],
                        "ajax" : {
                            "url" : "./ajax/TreeNode.ajax.php",
                            "data" : function(n) {
                                return {
                                    term_id : n.attr("id") == null? "0" : n.attr("id").split('_')[1]
                                };
                            }
                        },
                        "progressive_render" : true
                    },
                    "plugins" : [ "themes", "json_data", "contextmenu"],
                    "core":{
//                        "initially_load": ["li_0014667","li_0050117","li_0060035","li_14566","li_150","li_225","li_7","li_0050013","li_630"],
                        "initially_load": ["li_4241","li_1612","li_193","li_462","li_162","li_14566","li_4"],
                        "initially_open": ["li_4241"]
                    }
                }).bind("open_node.jstree", function (event, data) {
                    if((data.inst._get_parent(data.rslt.obj)).length) {
//                        data.inst._get_parent(data.rslt.obj).open_node(this, false);
                        data.inst.open_node(data.inst._get_parent(data.rslt.obj), false,true);
                    }
                });
            });
        function aaa(count){
            alert(count);
//            $("#dttree").jstree("open_node", $('#li_150'));
            $("#dttree").jstree("open_node", $('#li_12961'));
//            if (count == 0){
//                $("#dttree").jstree("open_node", $('#li_4'));
//            } else if (count == 1){
//                $("#dttree").jstree("open_node", $('#li_0014667'));
//            } else if (count == 2){
//                $("#dttree").jstree("open_node", $('#li_0050117'));
//            } else if (count == 3){
//                $("#dttree").jstree("open_node", $('#li_104'));
//            } else {
//                return;
//            }
//            
//            count++;
//            aaa(count);
        }
        </script>
    </head>
    <body>
        <div class="bborderx"> 
            <div class="treeview" id="dttree"></div>
        </div>
        <div><input type="button" value="try" onclick="aaa(0)"/></div>
    </body>
</html>
